﻿using System;
using System.Collections.Generic;
using System.Text;
using WebApiV3.Data.Entity;
using WebApiV3.Domain.Enom;
using WebApiV3.InterFace.Log;

namespace WebApiV3.Utils
{
    public static class LogHelper
    {
        public static void Logger(this ILog log, Exception exception, LogLevel logLevel , int userId = 0)
        {
            var item = new Logs
            {
                LogLevel = (int)logLevel,
                ShortMessage = exception.Message,
                FullMessage = exception.ToString(),
                UserId = userId
            };
            log.Insert(item);
        }
        public static void Info(this ILog log, Exception exception, LogLevel logLevel=LogLevel.信息, int userId = 0)
        {
            Logger(log, exception, logLevel, userId);
        }

        public static void Debug(this ILog log, Exception exception, LogLevel logLevel=LogLevel.调试, int userId = 0)
        {
            Logger(log, exception, logLevel, userId);
        }

        public static void Error(this ILog log, Exception exception, LogLevel logLevel = LogLevel.错误, int userId = 0)
        {
            Logger(log, exception, logLevel, userId);
        }

        public static void Fatal(this ILog log, Exception exception, LogLevel logLevel = LogLevel.崩溃, int userId = 0)
        {
            Logger(log, exception, logLevel, userId);
        }


    }
}
